package cn.south.campus.admin.campus.controller;

import cn.south.campus.admin.campus.model.req.CommentReq;
import cn.south.campus.admin.campus.model.vo.ComplaintCommentVo;
import cn.south.campus.admin.campus.service.CommentService;
import cn.south.campus.common.model.bo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chow
 * @since 2025-01-16
 */
@RestController
@RequestMapping("/admin/comment")
@AllArgsConstructor
public class CommentController {

    private final CommentService commentService;

    @DeleteMapping("/delete/{id}")
    public Result<String> delete(@PathVariable Long id) {
        commentService.delete(id);
        return Result.success("删除成功");
    }

    @GetMapping("page")
    public Result<IPage<ComplaintCommentVo>> page(CommentReq query) {
        return Result.success(commentService.pageQuery(query));
    }

    @GetMapping("pageByAncestor")
    public Result<IPage<ComplaintCommentVo>> pageByAncestor(CommentReq query) {
        return Result.success(commentService.pageByAncestor(query));
    }

    @GetMapping("getComment/{id}")
    public Result<ComplaintCommentVo> getComment(@PathVariable Long id) {
        return Result.success(commentService.getComment(id));
    }
}
